package phototour3.client;

import java.util.Comparator;

public class ComparatorNearer implements Comparator<Pnt> {
	
	private Pnt center;
	
	public ComparatorNearer(Pnt center) {
		super();
		this.setCenter(center);
	}

	@Override
	public int compare(Pnt o1, Pnt o2) {
		int i=0; 
		Double distanceo1=Math.abs(o1.coord(0)-center.coord(0))+Math.abs(o1.coord(0)-center.coord(1));
		Double distanceo2=Math.abs(o2.coord(0)-center.coord(0))+Math.abs(o2.coord(0)-center.coord(1));
		if(distanceo1<distanceo2){
			i=1;
		
		}else{
			i=-1;
		}
		return i;
	}

	public void setCenter(Pnt center) {
		this.center = center;
	}

	public Pnt getCenter() {
		return center;
	}

}
